﻿#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>

typedef double Real;


typedef struct
{
	int a0;
	int a;
	int b0;
	int b;
	int n;
}Context;
Context context = { 0 };


void read_data(Context* ctx)
{
	scanf("%d %d", &ctx->a, &ctx->b);
	ctx->a0 = ++ctx->a;
	ctx->b0 = ++ctx->b;
	scanf("%d", &ctx->n);
}

void play_round(Context* ctx)
{
	int a1, ah, b1, bh;
	scanf("%d %d %d %d", &a1, &ah, &b1, &bh);
	int aw = ah == a1 + b1;
	int bw = bh == a1 + b1;
	if (aw && bw)
		return;
	if (aw)
		ctx->a--;
	if (bw)
		ctx->b--;
}

void solve(Context* ctx)
{
	for (int i = 0; i < ctx->n; ++i)
	{
		play_round(ctx);
		if (ctx->a == 0 || ctx->b == 0)
			break;
	}
	if (ctx->a == 0) {
		printf("A\n%d\n", ctx->b0 - ctx->b);
	}
	else if (ctx->b == 0) {
		printf("B\n%d\n", ctx->a0 - ctx->a);
	}
}

int main()
{
	freopen("D:/Develop/GitRepos/MOOC/浙江大学/数据结构/201906/DataStructure/M2019秋C入门和进阶练习集/7-180.txt", "r", stdin);
	read_data(&context);
	solve(&context);
	return 0;
}
